home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / Xprof / xprof / request.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  47KB  |  1,493 lines

  1. /*==================================================================
  2.  *      File :          request.c
  3.  *      Package:        Xprof
  4.  *
  5.  *      Author :        Aloke Gupta.
  6.  *
  7.  *  (C) Copyright 1992, Aloke Gupta.
  8.  *==================================================================*/
  9.  
  10. /*
  11.  * Processing routines for the requests seen in the message stream.
  12.  * Functions:
  13.  *    1. process_request(FILE *fp, char *string, GlobalStats *globalstats)
  14.  *    2. print_request_stats(FILE *fp)
  15.  *    3. The routines to process each request seen. These have the format:
  16.  *           Request(FILE *fp, request_index, current_time)
  17.  */
  18. #include <stdio.h>
  19. #include "common.h"
  20. #include "profile.h"
  21.  
  22. MsgStats TotalRequestStats;        /* Overall stats for all requests */
  23. MsgStats RequestStats[MAXREQUESTS];    /* Detailed stats for each request */
  24.  
  25. static char in_string[MAXSTRINGSIZE];    /* Buffer to read a record into */
  26. static char sbuf[132], sbuf1[132], sbuf2[132]; /* Temp. slots for sscanf*/
  27.  
  28. extern MsgType  RequestType[];
  29. extern int lookup_request();
  30.  
  31. static Xattributes attributes;        /* Attributes of current message */
  32.  
  33. XprofGCvalues    *create_gcval();
  34. XprofGCvalues    *get_gcval();
  35. FontVal     *create_fontval();
  36. FontVal     *get_fontval();
  37.  
  38. process_request(fp, string, gstats)
  39. FILE *fp;                /* Pointer to input stream */
  40. char *string;
  41. GlobalStats *gstats;
  42. {
  43.     char request_name[80];        /* Name of the current request */
  44.     int  request_index;            /* Index in the data structures */
  45.     long bytes=0;            /* number of bytes */
  46.  
  47.     /* Initialize the data structures. */
  48.     if (TotalRequestStats.invoked == FALSE) 
  49.     InitMsgStats(&TotalRequestStats, gstats->current_time,DETAILED,GRAIN1);
  50.     /*
  51.      * Zero out the attributes structure. This is modified as a side effect by
  52.      * many of the action functions 
  53.      */
  54.     bzero((char *) &attributes, sizeof(Xattributes));
  55.  
  56.     sscanf(string, "%s %s",sbuf, request_name);
  57.  
  58.     request_index = lookup_request(request_name);
  59.  
  60.     /* Call the action for this request */
  61.     /* The action will fill the MsgStats for the request and also update
  62.      * the profile
  63.      */
  64.     bytes = RequestType[request_index].action(fp, request_index,
  65.             gstats->current_time);
  66.     /*
  67.      * Fill the data structure for the total of the requests. The size
  68.      * distribution is maintained for the total number of bytes received.
  69.      */
  70.     FillMsgStats(&TotalRequestStats, gstats->current_time, bytes, bytes); 
  71.  
  72.     gstats->request_bytes += bytes;
  73. }
  74.  
  75. print_request_stats(fp)
  76. FILE *fp;
  77. {
  78.     int i;
  79.     char *dashes = "---------------------------------------------------------------";
  80.  
  81.  
  82.     if (TotalRequestStats.invoked == FALSE)
  83.         return;
  84.     /*
  85.      * Print the details for all Requests together 
  86.      */
  87.     PrintMsgStats(fp,&TotalRequestStats, "REQUESTS ");
  88.  
  89.     /*
  90.      * Brief table for the numbers and byte totals for the requests
  91.      */
  92.     fprintf(fp, "\t%s\n", dashes);
  93.     fprintf(fp,"%-25s",  "        REQUEST messages");
  94.     fprintf(fp,"%25s",  "Total Bytes      ");
  95.     fprintf(fp," %19s\n","Number      ");
  96.     fprintf(fp, "\t%s\n", dashes);
  97.     for (i = 0; i < MAXREQUESTS; i++)
  98.       if (RequestStats[i].invoked == TRUE) {
  99.     fprintf(fp,"%-25s", RequestType[i].name);
  100.     fprintf(fp," %10ld bytes",RequestStats[i].total_bytes);
  101.     fprintf(fp," (%5.2f%%)", (float) 100 * RequestStats[i].total_bytes / 
  102.                 TotalRequestStats.total_bytes);
  103.     fprintf(fp," %10ld", RequestStats[i].number );
  104.     fprintf(fp," (%5.2f%%)", (float) 100 * RequestStats[i].number / 
  105.                 TotalRequestStats.number);
  106.         fprintf(fp,"\n");
  107.     }
  108.     fprintf(fp, "\t%s\n", dashes);
  109.     fprintf(fp,"%25s"," Grand Total      ");
  110.     fprintf(fp," %10ld bytes         ", TotalRequestStats.total_bytes);
  111.     fprintf(fp," %10ld         \n", TotalRequestStats.number);
  112.     fprintf(fp, "\t%s\n", dashes);
  113.     if (verboselevel > 0) {
  114.     for (i = 0; i < MAXREQUESTS; i++)
  115.       if (RequestStats[i].detailed == DETAILED) 
  116.           PrintMsgStats(fp,&RequestStats[i], RequestType[i].name);
  117.     }
  118.     /* 
  119.      * Now dump the raw statistics for the messages
  120.      */
  121.     if (verboselevel > 1) {
  122.     if (TotalRequestStats.detailed == DETAILED) 
  123.           PrintMsgDetails(fp,&TotalRequestStats, "REQUESTS ");
  124.  
  125.     for (i = 0; i < MAXREQUESTS; i++)
  126.       if (RequestStats[i].detailed == DETAILED) 
  127.           PrintMsgDetails(fp,&RequestStats[i], RequestType[i].name);
  128.     }
  129.     return;
  130. }
  131.  
  132. /*
  133.  * OpenFont: Opcode 45
  134.  * Size: 0 (Irrelevant)
  135.  */
  136. long OpenFont(fp, num, current_time)
  137. FILE *fp;        /* Data stream */
  138. int  num;        /* Number of the request */
  139. long current_time;    /* Current time in ms */
  140. {
  141.     long    bytes;
  142.     int     max_slots = 3;    /* Maximum number of data slots to fill */
  143.     int     length;
  144.     long    fontid;
  145.     Boolean fd_length = FALSE,  fd_fontid = FALSE, fd_name = FALSE;
  146.     int     fd_all=0;        /* All found ? */
  147.     char    *ptr;
  148.     FontVal *fontval;
  149.     int     strlength;
  150.  
  151.     if (RequestStats[num].invoked == FALSE) 
  152.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  153.                     RequestType[num].size_grain);
  154.     /*
  155.      * Get a record and fill all the slots
  156.      */
  157.     while (fd_all < max_slots) {
  158.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  159.         return(0);
  160.     _LINE_NUM++;
  161.     ptr = in_string;
  162.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  163.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  164.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  165.         fd_length = TRUE;    fd_all ++;
  166.         continue;
  167.     } 
  168.     else if ((fd_fontid==FALSE)&&(t_search(ptr,"font-id:")!= 0)){
  169.         sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &fontid);
  170.         fd_fontid = TRUE;    fd_all ++;
  171.         continue;
  172.     } 
  173.     else if ((fd_name==FALSE)&&(t_search(ptr,"name:")!= 0)){
  174.         sscanf(ptr,"%s %s", sbuf1, sbuf2);
  175.         fd_name = TRUE;    fd_all ++;
  176.         continue;
  177.     } 
  178.     }    /* while */
  179.  
  180.     /*
  181.      * Create and fill the FontVal structure for this font
  182.      */
  183.     fontval = create_fontval(fontid);
  184.     strlength = strlen(sbuf2);
  185.     sbuf2[--strlength] = '\0';
  186.     fontval->fontname= malloc(strlen(sbuf2));
  187.     strcpy(fontval->fontname, sbuf2+1);
  188.  
  189.     /*
  190.      * Fill the data Structure for this message
  191.      */
  192.     bytes         = length * 4;
  193.     attributes.bytes = bytes;
  194.     attributes.size  = 0.0;
  195.     update_profile(num, &attributes);
  196.     FillMsgStats(&RequestStats[num], current_time,
  197.                     (long) 0, bytes); 
  198.     return (bytes);
  199. }    /* OpenFont */
  200.  
  201. /*
  202.  * CloseFont: Opcode 46
  203.  * Size: 0 (Irrelevant)
  204.  */
  205. long CloseFont(fp, num, current_time)
  206. FILE *fp;        /* Data stream */
  207. int  num;        /* Number of the request */
  208. long current_time;    /* Current time in ms */
  209. {
  210.     long    bytes;
  211.     int     max_slots = 2;    /* Maximum number of data slots to fill */
  212.     int     length;
  213.     long    fontid;
  214.     Boolean fd_length = FALSE,  fd_fontid = FALSE;
  215.     int     fd_all=0;        /* All found ? */
  216.     char    *ptr;
  217.  
  218.     if (RequestStats[num].invoked == FALSE) 
  219.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  220.                     RequestType[num].size_grain);
  221.     /*
  222.      * Get a record and fill all the slots
  223.      */
  224.     while (fd_all < max_slots) {
  225.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  226.         return(0);
  227.     _LINE_NUM++;
  228.     ptr = in_string;
  229.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  230.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  231.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  232.         fd_length = TRUE;    fd_all ++;
  233.         continue;
  234.     } 
  235.     else if ((fd_fontid==FALSE)&&(t_search(ptr,"font:")!= 0)){
  236.         sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &fontid);
  237.         fd_fontid = TRUE;    fd_all ++;
  238.         continue;
  239.     } 
  240.     }    /* while */
  241.  
  242.     /* Clear out the font */
  243.     free_fontval(fontid);
  244.     /*
  245.      * Fill the data Structure for this message
  246.      */
  247.     bytes         = length * 4;
  248.     attributes.bytes = bytes;
  249.     attributes.size  = 0.0;
  250.     update_profile(num, &attributes);
  251.     FillMsgStats(&RequestStats[num], current_time,
  252.                     (long) 0, bytes); 
  253.     return (bytes);
  254. }    /* CloseFont */
  255.  
  256. /*
  257.  * CreateGC: Opcode 55
  258.  * Size: 0 (Irrelevant)
  259.  */
  260. long CreateGC(fp, num, current_time)
  261. FILE *fp;        /* Data stream */
  262. int  num;        /* Number of the request */
  263. long current_time;    /* Current time in ms */
  264. {
  265.     XprofGCvalues *gcval;    /* pointer to a relevent graphics context */
  266.     long    bytes;
  267.     int     max_slots = 4;    /* Maximum number of data slots to fill */
  268.     int     length, valmask=0;
  269.     long    gcid;
  270.     Boolean fd_length = FALSE,  fd_gcid = FALSE;
  271.     Boolean fd_valmask = FALSE, fd_vallist = FALSE;
  272.     int     fd_all=0;        /* All found ? */
  273.     char    *ptr;
  274.  
  275.     gcval = create_gcval(0);    /* Allocate gcval with gcid = 0 (reset below) */
  276.     if (RequestStats[num].invoked == FALSE) 
  277.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  278.                     RequestType[num].size_grain);
  279.     /*
  280.      * Get a record and fill all the slots
  281.      */
  282.     while (fd_all < max_slots) {
  283.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  284.         return(0);
  285.     _LINE_NUM++;
  286.     ptr = in_string;
  287.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  288.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  289.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  290.         fd_length = TRUE;    fd_all ++;
  291.         continue;
  292.     } 
  293.     else if ((fd_gcid==FALSE)&&(t_search(ptr,"graphic-context-id:")!= 0)){
  294.         sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  295.         fd_gcid = TRUE;    fd_all ++;
  296.         gcval->id = gcid;
  297.         continue;
  298.     } 
  299.     else if ((fd_valmask==FALSE)&&(t_search(ptr,"value-mask:")!= 0)){
  300.         fd_valmask = TRUE;    fd_all ++;
  301.         fill_gcmask(ptr, &valmask);
  302.         if (valmask == 0) {
  303.         fd_vallist = TRUE; fd_all ++; /* No values are to be set */
  304.         }
  305.         continue;
  306.     } 
  307.     else if ((fd_vallist==FALSE)&&(t_search(ptr,"value-list:")!= 0)){
  308.         fd_vallist = TRUE;    fd_all ++;
  309.         /*
  310.          * Now search for all the values that have been set
  311.          */
  312.         fill_gcval(fp, valmask, gcval);
  313.         continue;
  314.     } 
  315.     }    /* while */
  316. fflush(stdout);
  317.     /*
  318.      * Fill the data Structure for this message
  319.      */
  320.     attributes.gcval = gcval;
  321.     bytes         = length * 4;
  322.     attributes.bytes = bytes;
  323.     attributes.size  = 0.0;
  324.     update_profile(num, &attributes);
  325.     FillMsgStats(&RequestStats[num], current_time,
  326.                     (long) 0, bytes); 
  327.     return (bytes);
  328. }    /* CreateGC */
  329.  
  330. /*
  331.  * ChangeGC: Opcode 55
  332.  * Size: 0 (Irrelevant)
  333.  */
  334. long ChangeGC(fp, num, current_time)
  335. FILE *fp;        /* Data stream */
  336. int  num;        /* Number of the request */
  337. long current_time;    /* Current time in ms */
  338. {
  339.     XprofGCvalues *gcval;    /* pointer to a relevent graphics context */
  340.     long    bytes;
  341.     int     max_slots = 4;    /* Maximum number of data slots to fill */
  342.     int     length, valmask=0;
  343.     long    gcid;
  344.     Boolean fd_length = FALSE,  fd_gcid = FALSE;
  345.     Boolean fd_valmask = FALSE, fd_vallist = FALSE;
  346.     int     fd_all=0;        /* All found ? */
  347.     char    *ptr;
  348.  
  349.     if (RequestStats[num].invoked == FALSE) 
  350.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  351.                     RequestType[num].size_grain);
  352.     /*
  353.      * Get a record and fill all the slots
  354.      */
  355.     while (fd_all < max_slots) {
  356.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  357.         return(0);
  358.     _LINE_NUM++;
  359.     ptr = in_string;
  360.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  361.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  362.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  363.         fd_length = TRUE;    fd_all ++;
  364.         continue;
  365.     } 
  366.     else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  367.         sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  368.         fd_gcid = TRUE;    fd_all ++;
  369.         gcval = get_gcval(gcid);
  370.         continue;
  371.     } 
  372.     else if ((fd_valmask==FALSE)&&(t_search(ptr,"value-mask:")!= 0)){
  373.         fd_valmask = TRUE;    fd_all ++;
  374.         fill_gcmask(ptr, &valmask);
  375.         if (valmask == 0) {
  376.         fd_vallist = TRUE; fd_all ++; /* No values are to be set */
  377.         }
  378.         continue;
  379.     } 
  380.     else if ((fd_vallist==FALSE)&&(t_search(ptr,"value-list:")!= 0)){
  381.         fd_vallist = TRUE;    fd_all ++;
  382.         /*
  383.          * Now search for all the values that have been set
  384.          */
  385.         fill_gcval(fp, valmask, gcval);
  386.         continue;
  387.     } 
  388.     }    /* while */
  389. fflush(stdout);
  390.     /*
  391.      * Fill the data Structure for this message
  392.      */
  393.     attributes.gcval = gcval;
  394.     bytes         = length * 4;
  395.     attributes.bytes = bytes;
  396.     attributes.size  = 0.0;
  397.     update_profile(num, &attributes);
  398.     FillMsgStats(&RequestStats[num], current_time,
  399.                     (long) 0, bytes); 
  400.     return (bytes);
  401. }    /* ChangeGC */
  402.  
  403. /*
  404.  * CopyGC: Opcode 57
  405.  * Size: 0 (Irrelevant)
  406.  */
  407. long CopyGC(fp, num, current_time)
  408. FILE *fp;        /* Data stream */
  409. int  num;        /* Number of the request */
  410. long current_time;    /* Current time in ms */
  411. {
  412.     long    bytes;
  413.     int     max_slots = 4;    /* Maximum number of data slots to fill */
  414.     int     length, valmask=0;
  415.     long    src_gcid, dst_gcid;
  416.     Boolean fd_length  = FALSE, fd_srcgcid = FALSE;
  417.     Boolean fd_dstgcid = FALSE, fd_valmask = FALSE;
  418.     int     fd_all=0;        /* All found ? */
  419.     char    *ptr;
  420.  
  421.     if (RequestStats[num].invoked == FALSE) 
  422.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  423.                     RequestType[num].size_grain);
  424.     /*
  425.      * Get a record and fill all the slots
  426.      */
  427.     while (fd_all < max_slots) {
  428.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  429.         return(0);
  430.     _LINE_NUM++;
  431.     ptr = in_string;
  432.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  433.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  434.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  435.         fd_length = TRUE;    fd_all ++;
  436.         continue;
  437.     } 
  438.     else if ((fd_srcgcid==FALSE)&&(t_search(ptr,"src-gc:")!= 0)){
  439.         sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &src_gcid);
  440.         fd_srcgcid = TRUE;    fd_all ++;
  441.         continue;
  442.     } 
  443.     else if ((fd_dstgcid==FALSE)&&(t_search(ptr,"dst-gc:")!= 0)){
  444.         sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &dst_gcid);
  445.         fd_dstgcid = TRUE;    fd_all ++;
  446.         continue;
  447.     } 
  448.     else if ((fd_valmask==FALSE)&&(t_search(ptr,"value-mask:")!= 0)){
  449.         fd_valmask = TRUE;    fd_all ++;
  450.         fill_gcmask(ptr, &valmask);
  451.         continue;
  452.     } 
  453.     }    /* while */
  454.  
  455.     copy_gcval(src_gcid, dst_gcid, valmask);
  456.     /*
  457.      * Fill the data Structure for this message
  458.      */
  459.     bytes         = length * 4;
  460.     attributes.bytes = bytes;
  461.     attributes.size  = 0.0;
  462.     update_profile(num, &attributes);
  463.     FillMsgStats(&RequestStats[num], current_time,
  464.                     (long) 0, bytes); 
  465.     return (bytes);
  466. }    /* CopyGC */
  467.  
  468. /*
  469.  * FreeGC: Opcode 60
  470.  * Size: 0 (Irrelevant)
  471.  */
  472. long FreeGC(fp, num, current_time)
  473. FILE *fp;        /* Data stream */
  474. int  num;        /* Number of the request */
  475. long current_time;    /* Current time in ms */
  476. {
  477.     long    bytes;
  478.     int     max_slots = 2;    /* Maximum number of data slots to fill */
  479.     int     length;
  480.     long    gcid;
  481.     Boolean fd_length = FALSE,  fd_gcid = FALSE;
  482.     int     fd_all=0;        /* All found ? */
  483.     char    *ptr;
  484.  
  485.     if (RequestStats[num].invoked == FALSE) 
  486.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  487.                     RequestType[num].size_grain);
  488.     /*
  489.      * Get a record and fill all the slots
  490.      */
  491.     while (fd_all < max_slots) {
  492.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  493.         return(0);
  494.     _LINE_NUM++;
  495.     ptr = in_string;
  496.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  497.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  498.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  499.         fd_length = TRUE;    fd_all ++;
  500.         continue;
  501.     } 
  502.     else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  503.         sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  504.         fd_gcid = TRUE;    fd_all ++;
  505.         continue;
  506.     } 
  507.     }    /* while */
  508.     free_gcval(gcid);
  509.     /*
  510.      * Fill the data Structure for this message
  511.      */
  512.     bytes         = length * 4;
  513.     attributes.bytes = bytes;
  514.     attributes.size  = 0.0;
  515.     update_profile(num, &attributes);
  516.     FillMsgStats(&RequestStats[num], current_time,
  517.                     (long) 0, bytes); 
  518.     return (bytes);
  519. }    /* FreeGC */
  520.  
  521. /*
  522.  * ClearArea: Opcode 61
  523.  * Size: Area of image (height * width).
  524.  */
  525. long ClearArea(fp, num, current_time)
  526. FILE *fp;        /* Data stream */
  527. int  num;        /* Number of the request */
  528. long current_time;    /* Current time in ms */
  529. {
  530.     long   bytes;
  531.     int   max_slots = 3;    /* Maximum number of data slots to fill */
  532.     int   length, width, height;
  533.     Boolean fd_length = FALSE, fd_width  = FALSE, fd_height = FALSE;
  534.     int   fd_all=0;        /* All found ? */
  535.     char  *ptr;
  536.  
  537.     if (RequestStats[num].invoked == FALSE) 
  538.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  539.                         RequestType[num].size_grain);
  540.     /*
  541.      * Get a record and fill all the slots
  542.      */
  543.     while (fd_all < max_slots) {
  544.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  545.         return(0);
  546.     _LINE_NUM++;
  547.     ptr = in_string;
  548.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  549.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  550.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  551.         fd_length = TRUE;    fd_all ++;
  552.         continue;
  553.     } 
  554.     else if ((fd_width==FALSE)&&(t_search(ptr,"width:")!= 0)){
  555.         sscanf(ptr,"%s %x", sbuf1, &width);
  556.         fd_width = TRUE;    fd_all ++;
  557.         continue;
  558.     } 
  559.     else if ((fd_height==FALSE)&&(t_search(ptr,"height:")!= 0)){
  560.         sscanf(ptr,"%s %x", sbuf1, &height);
  561.         fd_height = TRUE;    fd_all ++;
  562.         continue;
  563.     } 
  564.     }    /* while */
  565.  
  566.     /*
  567.      * Fill the data Structure for this message
  568.      */
  569.     bytes         = length * 4;
  570.     attributes.size  = (float) height * width;
  571.     attributes.bytes = bytes;
  572.     update_profile(num, & attributes);
  573.     FillMsgStats(& RequestStats[num], current_time,
  574.             (long) height * width, bytes); 
  575.     return (bytes);
  576. }    /* ClearArea */
  577. /*
  578.  * CopyArea: Opcode 62
  579.  * Size: Area of image (height * width).
  580.  */
  581. long CopyArea(fp, num, current_time)
  582. FILE *fp;        /* Data stream */
  583. int  num;        /* Number of the request */
  584. long current_time;    /* Current time in ms */
  585. {
  586.     XprofGCvalues *gcval;
  587.     long  bytes;
  588.     int   max_slots = 4;    /* Maximum number of data slots to fill */
  589.     int   length, width, height;
  590.     long gcid;
  591.     Boolean fd_length = FALSE, fd_width  = FALSE, fd_height = FALSE;
  592.     Boolean fd_gcid   = FALSE;
  593.     int   fd_all=0;        /* All found ? */
  594.     char  *ptr;
  595.  
  596.     if (RequestStats[num].invoked == FALSE) 
  597.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  598.                         RequestType[num].size_grain);
  599.     /*
  600.      * Get a record and fill all the slots
  601.      */
  602.     while (fd_all < max_slots) {
  603.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  604.         return(0);
  605.     _LINE_NUM++;
  606.     ptr = in_string;
  607.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  608.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  609.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  610.         fd_length = TRUE;    fd_all ++;
  611.         continue;
  612.     } 
  613.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  614.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  615.             fd_gcid = TRUE;     fd_all ++;
  616.             gcval=get_gcval(gcid);
  617.             continue;
  618.         }
  619.     else if ((fd_width==FALSE)&&(t_search(ptr,"width:")!= 0)){
  620.         sscanf(ptr,"%s %x", sbuf1, &width);
  621.         fd_width = TRUE;    fd_all ++;
  622.         continue;
  623.     } 
  624.     else if ((fd_height==FALSE)&&(t_search(ptr,"height:")!= 0)){
  625.         sscanf(ptr,"%s %x", sbuf1, &height);
  626.         fd_height = TRUE;    fd_all ++;
  627.         continue;
  628.     } 
  629.     }    /* while */
  630.  
  631.     /*
  632.      * Fill the data Structure for this message
  633.      */
  634.     attributes.gcval = gcval;
  635.     bytes         = length * 4;
  636.     attributes.size  = (float) height * width;
  637.     attributes.bytes = bytes;
  638.     update_profile(num, & attributes);
  639.     FillMsgStats(& RequestStats[num], current_time,
  640.                     (long) height * width, bytes); 
  641.     return (bytes);
  642. }    /* CopyArea */
  643.  
  644. /*
  645.  * CopyPlane: Opcode 63
  646.  * Size: Area of the section to be copied.
  647.  */
  648. long CopyPlane(fp, num, current_time)
  649. FILE *fp;        /* Data stream */
  650. int  num;        /* Number of the request */
  651. long current_time;    /* Current time in ms */
  652. {
  653.     XprofGCvalues *gcval;
  654.     long  bytes;
  655.     int   max_slots = 4;    /* Maximum number of data slots to fill */
  656.     int   length, width, height;
  657.     long  gcid;
  658.     Boolean fd_length = FALSE, fd_width = FALSE, fd_height = FALSE;
  659.     Boolean fd_gcid   = FALSE;
  660.     int   fd_all=0;        /* All found ? */
  661.     char  *ptr;
  662.  
  663.     if (RequestStats[num].invoked == FALSE) 
  664.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  665.                     RequestType[num].size_grain);
  666.     /*
  667.      * Get a record and fill all the slots
  668.      */
  669.     while (fd_all < max_slots) {
  670.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  671.         return(0);
  672.     _LINE_NUM++;
  673.     ptr = in_string;
  674.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  675.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  676.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  677.         fd_length = TRUE;    fd_all ++;
  678.         continue;
  679.     } 
  680.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  681.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  682.             fd_gcid = TRUE;     fd_all ++;
  683.             gcval=get_gcval(gcid);
  684.             continue;
  685.         }
  686.     else if ((fd_width==FALSE)&&(t_search(ptr,"width:")!= 0)){
  687.         sscanf(ptr,"%s %x", sbuf1, &width);
  688.         fd_width = TRUE;    fd_all ++;
  689.         continue;
  690.     } 
  691.     else if ((fd_height==FALSE)&&(t_search(ptr,"height:")!= 0)){
  692.         sscanf(ptr,"%s %x", sbuf1, &height);
  693.         fd_height = TRUE;    fd_all ++;
  694.         continue;
  695.     } 
  696.     }    /* while */
  697.  
  698.     /*
  699.      * Fill the data Structure for this message
  700.      */
  701.     attributes.gcval = gcval;
  702.     bytes         = length * 4;
  703.     attributes.size  = (float) height * width;
  704.     attributes.bytes = bytes;
  705.     update_profile(num, & attributes);
  706.     FillMsgStats(& RequestStats[num], current_time,
  707.                     (long) height * width, bytes); 
  708.     return (bytes);
  709. }    /* CopyPlane */
  710.  
  711. /*
  712.  * PolyPoint: Opcode 64
  713.  * Size: Number of points.
  714.  */
  715. long PolyPoint(fp, num, current_time)
  716. FILE *fp;        /* Data stream */
  717. int  num;        /* Number of the request */
  718. long current_time;    /* Current time in ms */
  719. {
  720.     XprofGCvalues *gcval;
  721.     long    bytes;
  722.     int     max_slots = 3;    /* Maximum number of data slots to fill */
  723.     int     length, numpoints;
  724.     long    gcid;
  725.     Boolean fd_length = FALSE, fd_points = FALSE;
  726.     Boolean fd_gcid = FALSE;
  727.     int     fd_all=0;        /* All found ? */
  728.     int     i, x, y;
  729.     char *ptr;
  730.  
  731.     if (RequestStats[num].invoked == FALSE) 
  732.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  733.                         RequestType[num].size_grain);
  734.     /*
  735.      * Get a record and fill all the slots
  736.      */
  737.     while (fd_all < max_slots) {
  738.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  739.         return(0);
  740.     _LINE_NUM++;
  741.     ptr = in_string;
  742.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  743.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  744.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  745.         fd_length = TRUE;    fd_all ++;
  746.         continue;
  747.     } 
  748.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  749.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  750.             fd_gcid = TRUE;     fd_all ++;
  751.             gcval=get_gcval(gcid);
  752.             continue;
  753.         }
  754.     else if ((fd_points==FALSE)&&(t_search(ptr,"points:")!= 0)){
  755.         sscanf(ptr,"%s %s", sbuf1, sbuf2);
  756.         numpoints = atoi(&sbuf2[1]);/* The "points" field is base 10 !! */
  757.         fd_points = TRUE;    fd_all ++;
  758.         for (i = 0; i < numpoints ;i++) {    /* Read in each point */
  759.         fscanf(fp, "%s %x", sbuf1, &x);    _LINE_NUM++;    /* X */
  760.         fscanf(fp, "%s %x", sbuf1, &y);    _LINE_NUM++;    /* Y */
  761.         fscanf(fp, "%s",    sbuf1);     _LINE_NUM++;    /* Junk */
  762.         }
  763.         continue;
  764.     } 
  765.     }    /* while */
  766.  
  767.     /*
  768.      * Fill the data Structure for this message
  769.      */
  770.     attributes.gcval = gcval;
  771.     bytes         = length * 4;
  772.     attributes.size  = (float) numpoints;
  773.     attributes.bytes = bytes;
  774.     update_profile(num, & attributes);
  775.     FillMsgStats(& RequestStats[num], current_time, (long) numpoints, bytes); 
  776.     return (bytes);
  777. }    /* PolyPoint */
  778.  
  779. /*
  780.  * PolyLine: Opcode 66
  781.  * (Draw a connected line between the points listed).
  782.  * Size: The length of each line is registered.
  783.  */
  784. long PolyLine(fp, num, current_time)
  785. FILE *fp;        /* Data stream */
  786. int  num;        /* Number of the request */
  787. long current_time;    /* Current time in ms */
  788. {
  789.     XprofGCvalues *gcval;
  790.     long    bytes;
  791.     int     max_slots = 3;    /* Maximum number of data slots to fill */
  792.     int     length, points;
  793.     long    gcid;
  794.     Boolean fd_length = FALSE, fd_points = FALSE;
  795.     Boolean fd_gcid   = FALSE;
  796.     int     fd_all=0;        /* All found ? */
  797.     char    *ptr;
  798.     int i, x, y, old_x = 0, old_y = 0;
  799.     double line_length;
  800.  
  801.     if (RequestStats[num].invoked == FALSE) 
  802.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  803.                     RequestType[num].size_grain);
  804.     /*
  805.      * Get a record and fill all the slots
  806.      */
  807.     while (fd_all < max_slots) {
  808.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  809.         return(0);
  810.     _LINE_NUM++;
  811.     ptr = in_string;
  812.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  813.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  814.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  815.         fd_length = TRUE;    fd_all ++;
  816.         continue;
  817.     } 
  818.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  819.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  820.             fd_gcid = TRUE;     fd_all ++;
  821.             gcval=get_gcval(gcid);
  822.             continue;
  823.         }
  824.     else if ((fd_points==FALSE)&&(t_search(ptr,"points:")!= 0)){
  825.         sscanf(ptr,"%s %s", sbuf1, sbuf2);
  826.         points = atoi(&sbuf2[1]);    /* The "points" field is base 10 !! */
  827.         fd_points = TRUE;    fd_all ++;
  828.         for (i = 0; i < points ;i++) {     /* Read in each point */
  829.         fscanf(fp, "%s %x", sbuf1, &x); _LINE_NUM++;    /* X1 */
  830.         fscanf(fp, "%s %x", sbuf1, &y); _LINE_NUM++;    /* Y1 */
  831.         fscanf(fp, "%s",    sbuf1)    ;    _LINE_NUM++;    /* Junk */
  832.  
  833.         if (i > 0 ) {    /* It takes two to form a line */
  834.             line_length = sqrt( (double) ((old_x - x)*(old_x - x))
  835.                      +  ((old_y - y)*(old_y - y)) );
  836.             /* Now fill the data structure for all except the bytes*/
  837.             FillMsgStats(&RequestStats[num], current_time,
  838.                         (long) line_length, (long) -1); 
  839.             attributes.size  = length;
  840.             attributes.bytes = -1;
  841.             update_profile(num, & attributes);
  842.         }
  843.         old_x = x; old_y = y;
  844.         }
  845.     } 
  846.     }                /* while */
  847.     /*
  848.      * Fill the data Structure for this message
  849.      * Only the bytes are filled here
  850.      */
  851.     attributes.gcval = gcval;
  852.     bytes         = length * 4;
  853.     attributes.size  = -1.0;
  854.     attributes.bytes = bytes;
  855.     update_profile(num, & attributes);
  856.     FillMsgStats(&RequestStats[num], (long) -1, (long) -1, bytes); 
  857.     return (bytes);
  858. }    /* PolyLine */
  859.  
  860. /*
  861.  * PolySegment: Opcode 66
  862.  * Size: The length of each segment is registered.
  863.  */
  864. long PolySegment(fp, num, current_time)
  865. FILE *fp;        /* Data stream */
  866. int  num;        /* Number of the request */
  867. long current_time;    /* Current time in ms */
  868. {
  869.     XprofGCvalues *gcval;
  870.     long    bytes;
  871.     int     max_slots = 3;    /* Maximum number of data slots to fill */
  872.     int     length, segments;
  873.     long    gcid;
  874.     Boolean fd_length = FALSE, fd_segments = FALSE;
  875.     Boolean fd_gcid   = FALSE;
  876.     int     fd_all=0;        /* All found ? */
  877.     char    *ptr;
  878.     int     i, x1, y1, x2, y2;
  879.     double  seg_length;
  880.  
  881.     if (RequestStats[num].invoked == FALSE) 
  882.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  883.                     RequestType[num].size_grain);
  884.     /*
  885.      * Get a record and fill all the slots
  886.      */
  887.     while (fd_all < max_slots) {
  888.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  889.         return(0);
  890.     _LINE_NUM++;
  891.     ptr = in_string;
  892.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  893.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  894.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  895.         fd_length = TRUE;    fd_all ++;
  896.         continue;
  897.     } 
  898.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  899.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  900.             fd_gcid = TRUE;     fd_all ++;
  901.             gcval=get_gcval(gcid);
  902.             continue;
  903.         }
  904.     else if ((fd_segments==FALSE)&&(t_search(ptr,"segments:")!= 0)){
  905.         sscanf(ptr,"%s %s", sbuf1, sbuf2);
  906.         segments = atoi(&sbuf2[1]);    /* The "segments" field is base 10 !! */
  907.         fd_segments = TRUE;    fd_all ++;
  908.         for (i = 0; i < segments ;i++) {     /* Read in each segment */
  909.         fscanf(fp, "%s %x", sbuf1, &x1); _LINE_NUM++;    /* X1 */
  910.         fscanf(fp, "%s %x", sbuf1, &y1); _LINE_NUM++;    /* Y1 */
  911.         fscanf(fp, "%s %x", sbuf1, &x2); _LINE_NUM++;    /* X2 */
  912.         fscanf(fp, "%s %x", sbuf1, &y2); _LINE_NUM++;    /* Y2 */
  913.         fscanf(fp, "%s",    sbuf1);      _LINE_NUM++;    /* Junk */
  914.         /* Length of this segment ? */
  915.         seg_length = sqrt((double) ((x2 - x1)*(x2 - x1))
  916.                     +((y2 - y1)*(y2 - y1)));
  917.         /* Now fill the data structure for all values except the bytes*/
  918.         FillMsgStats(&RequestStats[num], current_time,
  919.                     (long) seg_length, (long) -1); 
  920.         attributes.size  = length;
  921.         attributes.bytes = -1;
  922.         update_profile(num, & attributes);
  923.         }
  924.     } 
  925.     }                /* while */
  926.     /*
  927.      * Fill the data Structure for this message
  928.      * Only the bytes are filled here
  929.      */
  930.     attributes.gcval = gcval;
  931.     bytes         = length * 4;
  932.     attributes.size  = -1.0;
  933.     attributes.bytes = bytes;
  934.     update_profile(num, & attributes);
  935.     FillMsgStats(&RequestStats[num], (long) -1, (long) -1, bytes); 
  936.     return (bytes);
  937. }    /* PolySegment */
  938.  
  939. /*
  940.  * PolyRectangle: Opcode 67
  941.  * Size: The perimeter of each rectangle is registered, i.e., 2*(width + height)
  942.  */
  943. long PolyRectangle(fp, num, current_time)
  944. FILE *fp;        /* Data stream */
  945. int  num;        /* Number of the request */
  946. long current_time;    /* Current time in ms */
  947. {
  948.     XprofGCvalues *gcval;
  949.     long    bytes;
  950.     int     max_slots = 3;    /* Maximum number of data slots to fill */
  951.     int     length, rectangles;
  952.     long    gcid;
  953.     Boolean fd_length = FALSE, fd_rectangles = FALSE;
  954.     Boolean fd_gcid   = FALSE;
  955.     int     fd_all=0;        /* All found ? */
  956.     char    *ptr;
  957.     int     i, x, y, width, height;
  958.  
  959.     if (RequestStats[num].invoked == FALSE) 
  960.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  961.                     RequestType[num].size_grain);
  962.     /*
  963.      * Get a record and fill all the slots
  964.      */
  965.     while (fd_all < max_slots) {
  966.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  967.         return(0);
  968.     _LINE_NUM++;
  969.     ptr = in_string;
  970.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  971.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  972.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  973.         fd_length = TRUE;    fd_all ++;
  974.         continue;
  975.     } 
  976.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  977.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  978.             fd_gcid = TRUE;     fd_all ++;
  979.             gcval=get_gcval(gcid);
  980.             continue;
  981.         }
  982.     else if ((fd_rectangles==FALSE)&&(t_search(ptr,"rectangles:")!= 0)){
  983.         sscanf(ptr,"%s %s", sbuf1, sbuf2);
  984.         rectangles = atoi(&sbuf2[1]);/*The "rectangles" field is base 10 !*/
  985.         fd_rectangles = TRUE;    fd_all ++;
  986.         for (i = 0; i < rectangles ;i++) {     /* Read in each rectangle */
  987.         fscanf(fp,"%s %x", sbuf1,&x);      _LINE_NUM++;    /* X */
  988.         fscanf(fp,"%s %x", sbuf1,&y);      _LINE_NUM++;    /* Y */
  989.         fscanf(fp,"%s %x", sbuf1,&width);  _LINE_NUM++;    /* width */
  990.         fscanf(fp,"%s %x", sbuf1,&height); _LINE_NUM++;    /* height */
  991.         fscanf(fp, "%s",    sbuf1);        _LINE_NUM++;    /* Junk */
  992.         /* Now fill the data structure for all values except the bytes*/
  993.         FillMsgStats(&RequestStats[num], current_time,
  994.                     (long) 2*(height+width), (long) -1); 
  995.         attributes.bytes = -1;
  996.         attributes.size  = 2 * (height + width);
  997.         update_profile(num, &attributes);
  998.         }
  999.     } 
  1000.     }                /* while */
  1001.     /*
  1002.      * Fill the data Structure for this message
  1003.      * Only the bytes are filled here
  1004.      */
  1005.     attributes.gcval = gcval;
  1006.     bytes         = length * 4;
  1007.     attributes.bytes = bytes;
  1008.     attributes.size  = -1.0;
  1009.     update_profile(num, &attributes);
  1010.     FillMsgStats(&RequestStats[num], (long) -1, (long) -1, bytes); 
  1011.     return (bytes);
  1012. }
  1013.  
  1014. /*
  1015.  * PolyFillRectangle: Opcode 70
  1016.  * Size: The area of each rectangle is registered, i.e., (width * height)
  1017.  */
  1018. long PolyFillRectangle(fp, num, current_time)
  1019. FILE *fp;        /* Data stream */
  1020. int  num;        /* Number of the request */
  1021. long current_time;    /* Current time in ms */
  1022. {
  1023.     XprofGCvalues *gcval;
  1024.     long    bytes;
  1025.     int     max_slots = 3;    /* Maximum number of data slots to fill */
  1026.     int     length, rectangles;
  1027.     long    gcid;
  1028.     Boolean fd_length = FALSE, fd_rectangles = FALSE;
  1029.     Boolean fd_gcid   = FALSE;
  1030.     int     fd_all=0;        /* All found ? */
  1031.     char    *ptr;
  1032.     int     i, x, y, width, height;
  1033.  
  1034.     if (RequestStats[num].invoked == FALSE) 
  1035.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  1036.                     RequestType[num].size_grain);
  1037.     /*
  1038.      * Get a record and fill all the slots
  1039.      */
  1040.     while (fd_all < max_slots) {
  1041.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  1042.         return(0);
  1043.     _LINE_NUM++;
  1044.     ptr = in_string;
  1045.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  1046.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  1047.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  1048.         fd_length = TRUE;    fd_all ++;
  1049.         continue;
  1050.     } 
  1051.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  1052.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  1053.             fd_gcid = TRUE;     fd_all ++;
  1054.             gcval=get_gcval(gcid);
  1055.             continue;
  1056.         }
  1057.     else if ((fd_rectangles==FALSE)&&(t_search(ptr,"rectangles:")!= 0)){
  1058.         sscanf(ptr,"%s %s", sbuf1, sbuf2);
  1059.         rectangles = atoi(&sbuf2[1]);/*The "rectangles" field is base 10 !*/
  1060.         fd_rectangles = TRUE;    fd_all ++;
  1061.         for (i = 0; i < rectangles ;i++) {     /* Read in each rectangle */
  1062.         fscanf(fp,"%s %x", sbuf1,&x);      _LINE_NUM++;    /* X */
  1063.         fscanf(fp,"%s %x", sbuf1,&y);      _LINE_NUM++;    /* Y */
  1064.         fscanf(fp,"%s %x", sbuf1,&width);  _LINE_NUM++;    /* width */
  1065.         fscanf(fp,"%s %x", sbuf1,&height); _LINE_NUM++;    /* height */
  1066.         fscanf(fp, "%s",    sbuf1);        _LINE_NUM++;    /* Junk */
  1067.         /* Now fill the data structure for all values except the bytes*/
  1068.         FillMsgStats(&RequestStats[num], current_time,
  1069.                     (long) (height*width), (long) -1); 
  1070.         attributes.bytes = -1;
  1071.         attributes.size  = height * width;
  1072.         update_profile(num, &attributes);
  1073.         }
  1074.     } 
  1075.     }                /* while */
  1076.     /*
  1077.      * Fill the data Structure for this message
  1078.      * Only the bytes are filled here
  1079.      */
  1080.     attributes.gcval = gcval;
  1081.     bytes         = length * 4;
  1082.     attributes.bytes = bytes;
  1083.     attributes.size  = height * width;
  1084.     update_profile(num, &attributes);
  1085.     FillMsgStats(&RequestStats[num], (long) -1, (long) -1, bytes); 
  1086.     return (bytes);
  1087. }    /* PolyFillRectangle */
  1088.  
  1089.  
  1090. /*
  1091.  * PutImage: Opcode 72
  1092.  * Size: Area of image (in bytes) i.e. (height * width * depth) / 8
  1093.  */
  1094. long PutImage(fp, num, current_time)
  1095. FILE *fp;        /* Data stream */
  1096. int  num;        /* Number of the request */
  1097. long current_time;    /* Current time in ms */
  1098. {
  1099.     XprofGCvalues *gcval;
  1100.     long    bytes;
  1101.     int     max_slots = 5;    /* Maximum number of data slots to fill */
  1102.     int     length, width, height, depth;
  1103.     long    gcid;
  1104.     Boolean fd_length=FALSE, fd_width=FALSE, fd_height=FALSE, fd_depth=FALSE;
  1105.     Boolean fd_gcid   = FALSE;
  1106.     int   fd_all=0;        /* All found ? */
  1107.     char  *ptr;
  1108.  
  1109.     if (RequestStats[num].invoked == FALSE) 
  1110.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  1111.                         RequestType[num].size_grain);
  1112.     /*
  1113.      * Fetch records until all the slots are filled. 
  1114.      */
  1115.     while (fd_all < max_slots) {
  1116.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  1117.         return(0);
  1118.     _LINE_NUM++;
  1119.     ptr = in_string;
  1120.     while (isspace(*ptr))    /* Remove leading white space */
  1121.         ptr++;
  1122.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  1123.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  1124.         fd_length = TRUE;    fd_all ++;
  1125.         continue;
  1126.     } 
  1127.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  1128.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  1129.             fd_gcid = TRUE;     fd_all ++;
  1130.             gcval=get_gcval(gcid);
  1131.             continue;
  1132.         }
  1133.     else if ((fd_width==FALSE)&&(t_search(ptr,"width:")!= 0)) {
  1134.         sscanf(ptr,"%s %x", sbuf1, &width);
  1135.         fd_width = TRUE;    fd_all ++;
  1136.         continue;
  1137.     } 
  1138.     else if ((fd_height==FALSE)&&(t_search(ptr,"height:")!= 0)) {
  1139.         sscanf(ptr,"%s %x", sbuf1, &height);
  1140.         fd_height = TRUE;    fd_all ++;
  1141.         continue;
  1142.     } 
  1143.     else if ((fd_depth==FALSE)&&(t_search(ptr,"depth:")!= 0)) {
  1144.         sscanf(ptr,"%s %x", sbuf1, &depth);
  1145.         fd_depth = TRUE;    fd_all ++;
  1146.         continue;
  1147.     } 
  1148.     }    /* while */
  1149.  
  1150.     /*
  1151.      * Fill the data Structure for this message
  1152.      */
  1153.     attributes.gcval = gcval;
  1154.     bytes         = length * 4;
  1155.     attributes.bytes = bytes;
  1156.     attributes.size  = (float) (height * width * depth) / 8;
  1157.     update_profile(num, &attributes);
  1158.     FillMsgStats(& RequestStats[num], current_time,
  1159.             (long) (height * width * depth) / 8, bytes); 
  1160.     return (bytes);
  1161. }    /* PutImage */
  1162.  
  1163. /*
  1164.  * GetImage: Opcode 73
  1165.  * Size: Area of image i.e. (height * width)
  1166.  */
  1167. long GetImage(fp, num, current_time)
  1168. FILE *fp;        /* Data stream */
  1169. int  num;        /* Number of the request */
  1170. long current_time;    /* Current time in ms */
  1171. {
  1172.     long   bytes;
  1173.     int   max_slots = 3;    /* Maximum number of data slots to fill */
  1174.     int   length, width, height;
  1175.     Boolean fd_length = FALSE, fd_width = FALSE, fd_height = FALSE;
  1176.     int   fd_all=0;        /* All found ? */
  1177.     char  *ptr;
  1178.  
  1179.     if (RequestStats[num].invoked == FALSE) 
  1180.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  1181.                     RequestType[num].size_grain);
  1182.     /*
  1183.      * Get a record and fill all the slots
  1184.      */
  1185.     while (fd_all < max_slots) {
  1186.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  1187.         return(0);
  1188.     _LINE_NUM++;
  1189.     ptr = in_string;
  1190.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  1191.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  1192.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  1193.         fd_length = TRUE;    fd_all ++;
  1194.         continue;
  1195.     } 
  1196.     else if ((fd_width==FALSE)&&(t_search(ptr,"width:")!= 0)){
  1197.         sscanf(ptr,"%s %x", sbuf1, &width);
  1198.         fd_width = TRUE;    fd_all ++;
  1199.         continue;
  1200.     } 
  1201.     else if ((fd_height==FALSE)&&(t_search(ptr,"height:")!= 0)){
  1202.         sscanf(ptr,"%s %x", sbuf1, &height);
  1203.         fd_height = TRUE;    fd_all ++;
  1204.         continue;
  1205.     } 
  1206.     }    /* while */
  1207.  
  1208.     /*
  1209.      * Fill the data Structure for this message
  1210.      */
  1211.     bytes = length * 4;
  1212.     attributes.bytes = bytes;
  1213.     attributes.size  = (float) height * width;
  1214.     update_profile(num, &attributes);
  1215.     FillMsgStats(& RequestStats[num], current_time,
  1216.                     (long) height * width, bytes); 
  1217.     return (bytes);
  1218. }    /* GetImage */
  1219.  
  1220. /*
  1221.  * PolyText8: Opcode 74
  1222.  * Size: length of string
  1223.  */
  1224. long PolyText8(fp, num, current_time)
  1225. FILE *fp;        /* Data stream */
  1226. int  num;        /* Number of the request */
  1227. long current_time;    /* Current time in ms */
  1228. {
  1229.     XprofGCvalues *gcval;
  1230.     long  bytes;
  1231.     int   max_slots = 3;    /* Maximum number of data slots to fill */
  1232.     int   length;        /* length and string are the two slots */
  1233.     char  *string;
  1234.     long  gcid;
  1235.     Boolean fd_length = FALSE, fd_string = FALSE, fd_gcid=FALSE;
  1236.     int   fd_all=0;        /* All found ? */
  1237.     char  *ptr;
  1238.     int   strlength;
  1239.  
  1240.     if (RequestStats[num].invoked == FALSE) 
  1241.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  1242.                     RequestType[num].size_grain);
  1243.     /*
  1244.      * Get a record and fill all the slots
  1245.      */
  1246.     while (fd_all < max_slots) {
  1247.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  1248.         return(0);
  1249.     _LINE_NUM++;
  1250.     ptr = in_string;
  1251.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  1252.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  1253.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  1254.         fd_length = TRUE;    fd_all ++;
  1255.         continue;
  1256.     } 
  1257.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  1258.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  1259.             fd_gcid = TRUE;     fd_all ++;
  1260.             gcval=get_gcval(gcid);
  1261.             continue;
  1262.         }
  1263.     else if ((fd_string==FALSE)&&(t_search(ptr,"text item 8 string:")!=0)){
  1264.         string = ptr + 21;
  1265.         strlength = strlen(string);
  1266.         while ((string[strlength-1]=='\n')||(string[strlength-1]=='"')) {
  1267.         string[strlength-1] = '\0';
  1268.         strlength --;
  1269.         }
  1270.         fd_string = TRUE;    fd_all ++;
  1271.         continue;
  1272.     } 
  1273.     }    /* while */
  1274.  
  1275.     /*
  1276.      * Fill the data Structure for this message
  1277.      */
  1278.     attributes.gcval=gcval;
  1279.     bytes         = length * 4;
  1280.     attributes.bytes = bytes;
  1281.     attributes.size  = (float) strlength;
  1282.     update_profile(num, &attributes);
  1283.     FillMsgStats(& RequestStats[num], current_time, (long) strlength, bytes); 
  1284.     return (bytes);
  1285. }    /* PolyText8 */
  1286.  
  1287. /*
  1288.  * PolyText16: Opcode 75
  1289.  * Size: length of string
  1290.  */
  1291. long PolyText16(fp, num, current_time)
  1292. FILE *fp;        /* Data stream */
  1293. int  num;        /* Number of the request */
  1294. long current_time;    /* Current time in ms */
  1295. {
  1296.     XprofGCvalues *gcval;
  1297.     long  bytes;
  1298.     int   max_slots = 3;    /* Maximum number of data slots to fill */
  1299.     int   length;        /* length and string are the two slots */
  1300.     char  *string;
  1301.     long  gcid;
  1302.     Boolean fd_length = FALSE, fd_string = FALSE, fd_gcid = FALSE;
  1303.     int   fd_all=0;        /* All found ? */
  1304.     char  *ptr;
  1305.     int   strlength;
  1306.  
  1307.     if (RequestStats[num].invoked == FALSE) 
  1308.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  1309.                     RequestType[num].size_grain);
  1310.     /*
  1311.      * Get a record and fill all the slots
  1312.      */
  1313.     while (fd_all < max_slots) {
  1314.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  1315.         return(0);
  1316.     _LINE_NUM++;
  1317.     ptr = in_string;
  1318.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  1319.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  1320.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  1321.         fd_length = TRUE;    fd_all ++;
  1322.         continue;
  1323.     } 
  1324.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  1325.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  1326.             fd_gcid = TRUE;     fd_all ++;
  1327.             gcval=get_gcval(gcid);
  1328.             continue;
  1329.         }
  1330.     else if ((fd_string==FALSE)&&(t_search(ptr,"text item 16 string:")!=0)){
  1331.         string = ptr + 22;
  1332.         strlength = strlen(string);
  1333.         while ((string[strlength-1]=='\n')||(string[strlength-1]=='"')) {
  1334.         string[strlength-1] = '\0';
  1335.         strlength --;
  1336.         }
  1337.         fd_string = TRUE;    fd_all ++;
  1338.         continue;
  1339.     } 
  1340.     }    /* while */
  1341.  
  1342.     /*
  1343.      * Fill the data Structure for this message
  1344.      */
  1345.     attributes.gcval = gcval;
  1346.     bytes         = length * 4;
  1347.     attributes.bytes = bytes;
  1348.     attributes.size  = (float) strlength;
  1349.     update_profile(num, &attributes);
  1350.     FillMsgStats(& RequestStats[num], current_time, (long) strlength, bytes); 
  1351.     return (bytes);
  1352. }    /* PolyText16 */
  1353.  
  1354.  
  1355.  
  1356. /*
  1357.  * ImageText8: Opcode 76
  1358.  * Size: length of string
  1359.  */
  1360. long ImageText8(fp, num, current_time)
  1361. FILE *fp;        /* Data stream */
  1362. int  num;        /* Number of the request */
  1363. long current_time;    /* Current time in ms */
  1364. {
  1365.     XprofGCvalues *gcval;
  1366.     long  bytes;
  1367.     int   max_slots = 3;    /* Maximum number of data slots to fill */
  1368.     int   length;        /* length and string are the two slots */
  1369.     char  *string;
  1370.     long gcid;
  1371.     Boolean fd_length = FALSE, fd_string = FALSE, fd_gcid=FALSE;
  1372.     int   fd_all=0;        /* All found ? */
  1373.     char  *ptr;
  1374.     int   strlength;
  1375.  
  1376.     if (RequestStats[num].invoked == FALSE) 
  1377.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  1378.                     RequestType[num].size_grain);
  1379.     /*
  1380.      * Get a record and fill all the slots
  1381.      */
  1382.     while (fd_all < max_slots) {
  1383.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  1384.         return(0);
  1385.     _LINE_NUM++;
  1386.     ptr = in_string;
  1387.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  1388.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  1389.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  1390.         fd_length = TRUE;    fd_all ++;
  1391.         continue;
  1392.     } 
  1393.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  1394.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  1395.             fd_gcid = TRUE;     fd_all ++;
  1396.             gcval=get_gcval(gcid);
  1397.             continue;
  1398.         }
  1399.     else if ((fd_string==FALSE)&&(t_search(ptr,"string:")!= 0)){
  1400.         string = ptr + 9;
  1401.         strlength = strlen(string);
  1402.         while ((string[strlength-1]=='\n')||(string[strlength-1]=='"')) {
  1403.         string[strlength-1] = '\0';
  1404.         strlength --;
  1405.         }
  1406.         fd_string = TRUE;    fd_all ++;
  1407.         continue;
  1408.     } 
  1409.     }    /* while */
  1410.  
  1411.     /*
  1412.      * Fill the data Structure for this message
  1413.      */
  1414.     attributes.gcval = gcval;
  1415.     bytes         = length * 4;
  1416.     attributes.bytes = bytes;
  1417.     attributes.size  = (float) strlength;
  1418.     update_profile(num, &attributes);
  1419.     FillMsgStats(& RequestStats[num], current_time,
  1420.                     (long) strlength, bytes); 
  1421.     return (bytes);
  1422. }    /* ImageText8 */
  1423.  
  1424. /*
  1425.  * ImageText16: Opcode 77
  1426.  * Size: length of string
  1427.  */
  1428. long ImageText16(fp, num, current_time)
  1429. FILE *fp;        /* Data stream */
  1430. int  num;        /* Number of the request */
  1431. long current_time;    /* Current time in ms */
  1432. {
  1433.     XprofGCvalues *gcval;
  1434.     long  bytes;
  1435.     int   max_slots = 3;    /* Maximum number of data slots to fill */
  1436.     int   length;        /* length and string are the two slots */
  1437.     char  *string;
  1438.     long  gcid;
  1439.     Boolean fd_length = FALSE, fd_string = FALSE, fd_gcid = FALSE;
  1440.     int   fd_all=0;        /* All found ? */
  1441.     char  *ptr;
  1442.     int   strlength;
  1443.  
  1444.  
  1445.     if (RequestStats[num].invoked == FALSE) 
  1446.     InitMsgStats(&RequestStats[num],current_time,RequestType[num].detailed,
  1447.                     RequestType[num].size_grain);
  1448.     /*
  1449.      * Get a record and fill all the slots
  1450.      */
  1451.     while (fd_all < max_slots) {
  1452.     if (fgets(in_string,MAXSTRINGSIZE,fp) == NULL)
  1453.         return(0);
  1454.     _LINE_NUM++;
  1455.     ptr = in_string;
  1456.     while (isspace(*ptr)) ptr++;    /* Remove leading white space */
  1457.     if ((fd_length==FALSE) && (t_search(ptr,"request length:")!= 0)) {
  1458.         sscanf(ptr,"%s %s %x", sbuf1, sbuf2, &length);
  1459.         fd_length = TRUE;    fd_all ++;
  1460.         continue;
  1461.     } 
  1462.         else if ((fd_gcid==FALSE)&&(t_search(ptr,"gc:")!= 0)){
  1463.             sscanf(ptr,"%s %s %lx", sbuf1, sbuf2, &gcid);
  1464.             fd_gcid = TRUE;     fd_all ++;
  1465.             gcval=get_gcval(gcid);
  1466.             continue;
  1467.         }
  1468.     else if ((fd_string==FALSE)&&(t_search(ptr,"string:")!= 0)){
  1469.         string = ptr + 9;
  1470.         strlength = strlen(string);
  1471.         while ((string[strlength-1]=='\n')||(string[strlength-1]=='"')) {
  1472.         string[strlength-1] = '\0';
  1473.         strlength --;
  1474.         }
  1475.         fd_string = TRUE;    fd_all ++;
  1476.         continue;
  1477.     } 
  1478.     }    /* while */
  1479.  
  1480.     /*
  1481.      * Fill the data Structure for this message
  1482.      */
  1483.     attributes.gcval = gcval;
  1484.     bytes         = length * 4;
  1485.     attributes.bytes = bytes;
  1486.     attributes.size  = (float) strlength;
  1487.     update_profile(num, &attributes);
  1488.     FillMsgStats(& RequestStats[num], current_time,
  1489.                     (long) strlength, bytes); 
  1490.     return (bytes);
  1491. }    /* ImageText16 */
  1492.  
  1493.